<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得图像类型的文件后缀</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.image-type-to-extension" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">image_type_to_extension</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7)</p><p class="refpurpose"><span class="refname">image_type_to_extension</span> &mdash; <span class="dc-title">取得图像类型的文件后缀</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.image-type-to-extension-description">
    <h3 class="title">说明</h3>
 <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>image_type_to_extension</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$imagetype</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$include_dot</code><span class="initializer"> = <strong><code>TRUE</code></strong></span></span>
  ] ) : <span class="type">string</span></div>

    <p class="para rdfs-comment">
     根据给定的常量 <em>IMAGETYPE_XXX</em> 返回后缀名。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.image-type-to-extension-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">imagetype</code></dt>

     <dd>

      <p class="para">
       <em>IMAGETYPE_XXX</em> 系列常量之一。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">include_dot</code></dt>

     <dd>

      <p class="para">
       是否在后缀名前加一个点。默认是 <strong><code>TRUE</code></strong>。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.image-type-to-extension-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   根据指定的图像类型返回对应的后缀名。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.image-type-to-extension-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3650">
    <p><strong>Example #1 <span class="function"><strong>image_type_to_extension()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;创建图像实例<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;保存图像<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'./test'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">image_type_to_extension</span><span style="color: #007700">(</span><span style="color: #0000BB">IMAGETYPE_PNG</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.image-type-to-extension-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">此函数不需要 GD 图象库。</p></p></blockquote>
 </div>

</div></div></div></body></html>